package com.jvyou.factory;

/**
 * @author 橘柚
 * @version 1.0-SNAPSHOT
 * @Date 2024/7/6 18:49
 * @Description 返现促销，满多少减多少
 */
public class CashbackPromotion implements Promotion {

    // 返现金额
    private final Double cashback;

    // 满多少
    private final Double minPrice;

    public CashbackPromotion(Double cashback, Double minPrice) {
        this.cashback = cashback;
        this.minPrice = minPrice;
    }

    @Override
    public Double applyPromotion(Double price) {
        return price - Math.floor(price / minPrice) * cashback;
    }
}
